
/**
 * Module dependencies.
 */

var express = require('express')
  , game = require('./routes/game')
  , http = require('http')
  , path = require('path');

var app = express();

// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
  app.use(require('less-middleware')({ src: __dirname + '/public' }));
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

app.get('/letters', game.getLetters);
app.post('/register', game.register);
app.get('/ping', game.ping);
app.post('/ready', game.ready);
app.get('/games', game.printGames);
app.post('/newGame', game.newGame);
app.post('/submitWord', game.submitWord);
app.get('/words', game.printWords);
app.get('/time', game.getTimeRemaining);
app.get('/results', game.getResults);
app.get('/game', game.getGame);
app.post('/quit', game.quit);

http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});
